import "babel-polyfill";
import Vue from "vue";
// import "./utils/rem";
import "./plugins/ElementUI";
import "normalize.css/normalize.css";
import "./styles/element-variables.scss";
import "./styles/global.scss";
import "./styles/element.scss";
import storage from "./utils/storage";
import Cookies from "./utils/cookies";
import "./components";
import * as directives from "./directives";
import * as utils from "./utils/utils";
import elTableInfiniteScroll from "el-table-infinite-scroll";
import i18n from "./lang";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import xss from "xss";
import draggable from "vuedraggable";
// import "./flexible";
// 兼容IE scrollTo
if (!window.scrollTo) {
  window.scrollTo = function (option) {
    window.scrollLeft = option.left;
    window.scrollTop = option.top;
  };
}

if (!document.body.scrollTo) {
  Element.prototype.scrollTo = function (option) {
    this.scrollLeft = option.left;
    this.scrollTop = option.top;
  };
}

Vue.component("draggable", draggable);
// 全局工具函数
Object.keys(utils).forEach((key) => {
  Vue.prototype[key] = utils[key];
});

// 全局注册指令
Object.keys(directives).forEach((key) => {
  Vue.directive(key, directives[key]);
});

//全局注册组件
Vue.use(elTableInfiniteScroll);
Vue.prototype.$storage = storage;
Vue.prototype.$cookies = Cookies;
Vue.prototype.$xss = xss;
Vue.config.productionTip = false;

new Vue({
  router,
  store,
  i18n,
  render: (h) => h(App),
}).$mount("#app");
